package com.tools.service.impl;

import com.tools.commons.utils.BeanUtils;
import com.tools.model.entity.UserAuthRelEntity;
import com.tools.model.entity.UserEntity;
import com.tools.model.entity.UserHistoryRelEntity;
import com.tools.model.params.UserHistoryParams;
import com.tools.repository.UserAuthRelRepository;
import com.tools.repository.UserHistoryRepository;
import com.tools.repository.UserRepository;
import com.tools.service.UserHistoryService;
import com.tools.service.UserInfoService;
import com.tools.utils.SendSms;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
@RequiredArgsConstructor
public class UserHistoryServiceImpl implements UserHistoryService {
    private final UserHistoryRepository userHistoryRepository;
    private final UserRepository userRepository;

    @Override
    public void save(UserHistoryParams userHistoryParams) {
        UserHistoryRelEntity userHistoryRelEntity = new UserHistoryRelEntity();
        BeanUtils.updateProperties(userHistoryParams, userHistoryRelEntity);
        userHistoryRepository.save(userHistoryRelEntity);
    }

    @Override
    public List<UserHistoryRelEntity> findByUserId(String id) {
        return userHistoryRepository.findAllByUserId(id);
    }
}
